home *** CD-ROM | disk | FTP | other *** search
- #include"genji.h"
-
- void incNest( int i )
- {
- nest[np+1] = i;
- info[np+1][0] = info[np][0];
- info[np+1][1] = info[np][1];
- ++ np;
-
- return;
- }
-
- int setInit( char *cnfname )
- {
- FILE *fp;
- int i;
- double d;
- char fntname[64];
- char buf[256],buf2[256];
-
- if( ( fp = fopen( cnfname, "r" ) ) == NULL )
- return ERR;
-
- xfgets( fntname, fp );
- if( ( mint_fp = fopen( fntname, "rb" ) ) == NULL )
- {
- mint_flg = OFF;
- VC_printf( "明朝体48ドットフォントを使用しません。\n" );
- }
- else
- {
- mint_flg = ON;
- VC_printf( "'%s'を明朝体48ドットフォントとして使用します。\n", POINTER, fntname );
- }
-
- xfgets( fntname, fp );
- if( ( goth_fp = fopen( fntname, "rb" ) ) == NULL )
- {
- goth_flg = OFF;
- VC_printf( "ゴシック体48ドットフォントを使用しません。\n" );
- }
- else
- {
- goth_flg = ON;
- VC_printf( "'%s'をゴシック体48ドットフォントとして使用します。\n", POINTER, fntname );
- }
-
- xfgets( fntname, fp );
- if( ( mouh_fp = fopen( fntname, "rb" ) ) == NULL )
- {
- mouh_flg = OFF;
- VC_printf( "毛筆体48ドットフォントを使用しません。\n" );
- }
- else
- {
- mouh_flg = ON;
- VC_printf( "'%s'を毛筆体48ドットフォントとして使用します。\n", POINTER, fntname );
- }
-
- xfgets( fntname, fp );
- if( ( maru_fp = fopen( fntname, "rb" ) ) == NULL )
- {
- maru_flg = OFF;
- VC_printf( "丸文字24ドットフォントを使用しません。\n" );
- }
- else
- {
- maru_flg = ON;
- VC_printf( "'%s'を丸文字24ドットフォントとして使用します。\n", POINTER, fntname );
- }
-
- xfgets( fntname, fp );
- if( ( kyou_fp = fopen( fntname, "rb" ) ) == NULL )
- {
- kyou_flg = OFF;
- VC_printf( "教科書体24ドットフォントを使用しません。\n" );
- }
- else
- {
- kyou_flg = ON;
- VC_printf( "'%s'を教科書体24ドットフォントとして使用します。\n", POINTER, fntname );
- }
-
- fscanf( fp, "%d", &i );
- if( i == 0 )
- writepage = OFF;
- else
- writepage = ON;
-
- fscanf( fp, "%d", &i );
- if( i > 0 )
- lpp = i;
- else
- lpp = 0;
-
- fscanf( fp, "%d", &i );
- if( i<0 || i>80 )
- VC_printf( "レフトマージンの設定が間違ってます。\n" );
- else
- leftmargin = i;
-
- fscanf( fp, "%d", &i );
- if( i<1 || i>8 )
- VC_printf( "タブサイズの設定が間違ってます。\n" );
- else
- tabsize = i;
-
- fclose( fp );
- return;
- }
-
- void convert24to48( char *gj24, char *gj48 )
- {
- int i,j;
-
- for( i=0; i<72; i++ )
- {
- *gj48 = 0;
- *gj48 |= ( (gj24[i]&128) | ((gj24[i]&128)>>1) );
- *gj48 |= ( ((gj24[i]&64)>>1) | ((gj24[i]&64)>>2) );
- *gj48 |= ( ((gj24[i]&32)>>2) | ((gj24[i]&32)>>3) );
- *gj48 |= ( ((gj24[i]&16)>>3) | ((gj24[i]&16)>>4) );
- ++gj48;
- *gj48 = 0;
- *gj48 |= ( ((gj24[i]&8)<<4) | ((gj24[i]&8)<<3) );
- *gj48 |= ( ((gj24[i]&4)<<3) | ((gj24[i]&4)<<2) );
- *gj48 |= ( ((gj24[i]&2)<<2) | ((gj24[i]&2)<<1) );
- *gj48 |= ( ((gj24[i]&1)<<1) | (gj24[i]&1) );
- ++gj48;
- if( (i+1)%3 == 0 )
- {
- for( j=0; j<6; j++ )
- *gj48++ = *(gj48-6);
- }
- }
- return;
- }
-
- void num2str( int *st, int number, int length )
- {
- int d = 1;
- int i;
-
- for( i=0; i<length; i++ )
- {
- st[length-i-1] = ( number % (d*10) ) / d;
- d *= 10;
- }
-
- return;
- }
-
- int getOneSegment( const char *p, char *q )
- {
- char *t;
- if( *p++ != '(' )
- return ERR;
-
- strncpy( q, p, 64 );
- t = memchr( q, ')', 64 );
- if( t == NULL )
- return ERR;
- *t = 0;
- return NOERR;
- }
-
- int xfgets( char *fn, FILE *fp )
- {
- if( fgets( fn, 256, fp ) == NULL )
- return ERR;
-
- while( *fn != '\n' && *fn != 0 )
- ++ fn;
-
- *fn = 0;
-
- return NOERR;
- }
-
- int addstrings( const char *s, char *t )
- {
- int i = 0;
-
- while( *s )
- {
- *t++ = *s++;
- i++;
- }
- *t = 0;
- return i;
- }
-
- int cmpstrings( const char *s, const char *t )
- {
- size_t l;
-
- l = strlen( t );
- if( strncmp( s, t, l ) )
- return 0;
- else
- return 1;
- }
-
- int printStrings( int n, char *p )
- {
- int i,e;
-
- if( n )
- {
- for( i=0; i<n; i++ )
- {
- if( e = PRN_putc( *(p+i) ) )
- return e;
- }
- }
- else
- {
- while( *p )
- {
- if( e = PRN_putc( *p ) )
- return e;
- ++ p;
- }
- }
- return 0;
- }
-
- typedef struct
- {
- char *command;
- int flag; /* 引き数フラグ flag & 1 ネストフラグ flag & 0x10 */
- int ret;
- } COMM ;
-
- COMM comdata[]={ { "h1byte", 0, 1 },
- { "up", 16, 2 },
- { "down", 16, 4 },
- { "kanjipitch", 1, 6 },
- { "retpitch", 1, 8 },
- { "normal", 16, 10 },
- { "wide", 16, 11 },
- { "tall", 16, 12 },
- { "large", 16, 13 },
- { "halftall", 16, 14 },
- { "halfwide", 16, 15 },
- { "h_t_wide", 16, 16 },
- { "h_w_tall", 16, 17 },
- { "small", 16, 18 },
- { "gothic", 16, 19 },
- { "mintyo", 16, 20 },
- { "underline", 16, 21 },
- { "connect_on", 0, 27 },
- { "connect_off", 0, 28 },
- { "set_top", 0, 29 },
- { "set_bottom", 0, 30 },
- { "set_center", 0, 31 },
- { "proportion", 16, 32 },
- { "next", 0, 38 },
- { "leftmargin", 1, 39 },
- { "net", 17, 40 },
- { "v_write", 0, 41 },
- { "h_write", 0, 42 },
- { "mouhitu", 16, 43 },
- { "maru", 16, 44 },
- { "kyou", 16, 45 },
- { "jis", 1, 46 },
- { "col_rev", 16, 47 },
- { "tabsize", 1, 48 },
- { NULL, 0, 0 } };
-
- int getCommand2()
- {
- int i,j;
- char buf[256];
- double w;
-
- i = 0;
- while( comdata[i].command != NULL )
- {
- if( cmpstrings( file, comdata[i].command ) )
- {
- file += strlen( comdata[i].command );
- if( comdata[i].flag & 1 )
- {
- pool[1] = 1;
- while(1)
- {
- if( getOneSegment( file, buf ) )
- {
- pool[1] = 0;
- break;
- }
- if( calcvalue( buf, &w ) )
- {
- pool[1] = 0;
- break;
- }
- j = w;
- DWORD( pool+2 ) = j;
- file += ( strlen( buf ) + 2 );
- break;
- }
- }
- if( comdata[i].flag & 16 )
- {
- if( *file == '{' )
- {
- pool[0] = 1;
- ++ file;
- }
- else
- pool[0] = 0;
- }
- return comdata[i].ret;
- }
- ++ i;
- }
-
- return 0xffff;
- }
-
- int printReady( int e )
- {
- int ch,ec;
-
- if( e > 6 )
- e = 7;
-
- VC_printf( "%s\n準備が出来たら何かキーを押してください。(<a> abort)\n", POINTER, errmes[e] );
- KYB_clrbuf();
- ch = KYB_read( 0, &ec );
- if( ch == 'a' || ch == 'A' )
- return 1;
-
- return 0;
- }
-
- void end_()
- {
- if( mint_flg == ON )
- fclose( mint_fp );
- if( goth_flg == ON )
- fclose( goth_fp );
- if( mouh_flg == ON )
- fclose( mouh_fp );
- if( maru_flg == ON )
- fclose( maru_fp );
- if( kyou_flg == ON )
- fclose( kyou_fp );
-
- return;
- }